package com.twu.biblioteca;

public class Movie {
    private String name;
    private int year;
    private String director;
    private int rating;

    public Movie(String name, int year, String director, int rating) {
        try {
            setRating(rating);
            this.name = name;
            this.year = year;
            this.director = director;
        } catch (RatingException e) {
            System.out.println("The rating needs to be on a 1-10 scale");
        }


    }

    public Movie(String name, int year, String director) {
        this.name = name;
        this.year = year;
        this.director = director;
        this.rating = 0;
    }


    public String getName() {
        return name;
    }

    public int getYear() {
        return year;
    }

    public String getDirector() {
        return director;
    }

    public int getRating() {
        return rating;
    }

    private void setRating(int rating) throws RatingException {
        if (1 <= rating && rating <= 10)
            this.rating = rating;
        else
            throw new RatingException();
    }
}
